package com.dkd.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.dkd.manage.domain.vo.ReportRepairVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dkd.common.annotation.Log;
import com.dkd.common.core.controller.BaseController;
import com.dkd.common.core.domain.AjaxResult;
import com.dkd.common.enums.BusinessType;
import com.dkd.manage.domain.ReportRepair;
import com.dkd.manage.service.IReportRepairService;
import com.dkd.common.utils.poi.ExcelUtil;
import com.dkd.common.core.page.TableDataInfo;

/**
 * 报修管理Controller
 * 
 * @author czq
 * @date 2024-11-09
 */
@RestController
@RequestMapping("/manage/repairReport")
public class ReportRepairController extends BaseController
{
    @Autowired
    private IReportRepairService reportRepairService;

    /**
     * 查询报修管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:repairReport:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReportRepair reportRepair)
    {
        startPage();
        List<ReportRepairVo> voList = reportRepairService.selectReportRepairVoList(reportRepair);
        return getDataTable(voList);
    }

    /**
     * 导出报修管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:repairReport:export')")
    @Log(title = "报修管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReportRepair reportRepair)
    {
        List<ReportRepair> list = reportRepairService.selectReportRepairList(reportRepair);
        ExcelUtil<ReportRepair> util = new ExcelUtil<ReportRepair>(ReportRepair.class);
        util.exportExcel(response, list, "报修管理数据");
    }

    /**
     * 获取报修管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:repairReport:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(reportRepairService.selectReportRepairById(id));
    }

    /**
     * 新增报修管理
     */
    @PreAuthorize("@ss.hasPermi('manage:repairReport:add')")
    @Log(title = "报修管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReportRepair reportRepair)
    {
        return toAjax(reportRepairService.insertReportRepair(reportRepair));
    }

    /**
     * 修改报修管理
     */
    @PreAuthorize("@ss.hasPermi('manage:repairReport:edit')")
    @Log(title = "报修管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReportRepair reportRepair)
    {
        return toAjax(reportRepairService.updateReportRepair(reportRepair));
    }

    /**
     * 删除报修管理
     */
    @PreAuthorize("@ss.hasPermi('manage:repairReport:remove')")
    @Log(title = "报修管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(reportRepairService.deleteReportRepairByIds(ids));
    }
}
